<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class PurchaseChild extends BaseModel
{
    use HasFactory;
    protected $table = 'purchase_child';
    // 允许批量操作的字段
    protected $fillable = [
        'purchase_id',
        'material_id',
        'num',
        'model_number_id',
        'specification_id',
        'color_id',
        'remark',
        'supplier_id',
        'is_del',
        'status',
        'warehouse_id',
        'goods_shelf_id',
        'created_at',
        'updated_at',
    ];

    public function scopeSearch($query,$params)
    {
        return $query;
    }


    public function material(){
        return $this->hasOne(Material::class,'id','material_id');
    }

    public function supplier(){
        return $this->hasOne(Supplier::class,'id','supplier_id');
    }

    public function warehouse(){
        return $this->hasOne(Warehouse::class,'id','warehouse_id');
    }

}
